#ifndef AUDIOHANDLER_H
#define AUDIOHANDLER_H

#include <QObject>
#include <QAudio>
#include <QAudioFormat>
#include <QAudioInput>
#include <QAudioOutput>
#include <QUdpSocket>

struct AudioPackage
{
    char name[64];
    char data[1024];
    int dataLen;
};

class AudioHandler : public QObject
{
    Q_OBJECT
public:
    explicit AudioHandler(QString userName, QString ip, quint16 port, QObject *parent = nullptr);
public slots:
    void onCbAudio();
    void captureDataFromDevice();
    void onReadyReadAudio();
    void onStateChange(QAudio::State state);

private:
    QString userName;
    QString ip;
    quint16 port;
    QUdpSocket *socketAudio = nullptr;
    QAudioInput *audioInput = nullptr;
    QIODevice *audioInputIODevice = nullptr;
    QAudioOutput *audioOutput = nullptr;
    QIODevice *audioOutputIODevice = nullptr;


signals:
    void stateChange(QAudio::State state);
};

#endif // AUDIOHANDLER_H
